const pattern = /(?<=\/)(\d(\/|$))/g

export default class DateUtils {
  // 获取当前日期
  static getToday() {
    const date = new Date().toLocaleDateString()
    const result = date.replace(pattern, '0$1').replace(/\//g, '-')
    return result
  }
  // 获取一周前日期
  static getWeekAgoDate() {
    const time = new Date().getTime() - 7 * 24 * 60 * 60 * 1000
    const targetTime = new Date(time).toLocaleDateString()
    const weekAgoDate = targetTime.replace(pattern, '0$1').replace(/\//g, '-')
    return weekAgoDate
  }
}
